﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using System.Data;
using System.Data.SqlClient;
public partial class News : System.Web.UI.Page
{

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            judje();
        }
    }

    protected override void OnPreRender(EventArgs e)
    {
        base.OnPreRender(e);
        judje();
    }

    /// <summary>
    /// 判断
    /// </summary>
    private void judje()
    {
        if (Request.QueryString["Cat"] != null && Request.QueryString["Cat"] != "")
        {
            BindWithCat(Request.QueryString["Cat"]);
        }
        else { BindWithCat(""); }
    }
    
    
    /// <summary>
    /// 查询新闻
    /// 2010 11 18
    /// 水亚亚
    /// </summary>
    /// <param name="cat">分类</param>
    private void BindWithCat(string cat)
    {
        try
        {
            string sql1 = "select newsID,newsType,newsTime,newsTop,newsTitle,newsHot from News_Info where newsIsShow=1 and newsType='" + cat + "' order by newsTop desc, newsTime desc";
            string sql2 = "select newsID,newsType,newsTime,newsTitle,newsTop,newsHot from News_Info where newsIsShow=1 order by newsTop desc, newsTime desc";
            string sql = cat == "" ? sql2 : sql1;
            DataTable dt = DataAccess.GetDataTable(sql, null);
            newsList.DataSource = dt;
            newsList.DataBind();
            lblTitleTop.Text = (Request.QueryString["Cat"] == null ? "" : Request.QueryString["Cat"]);
            
        }
        catch
        {

        }


    }
  
  
    
}